package com.ms.education.order.service;

import com.ms.education.order.entity.Order;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

/**
 * <p>
 * 订单 服务类
 * </p>
 *
 * @author ms
 * @since 2023-02-16
 */
public interface OrderService extends IService<Order> {

    String addOrder(Integer courseId, int userId, Integer type);

    /**
     * 根据订单号查询订单
     * @param orderNo 订单号
     * @return 订单
     */
    Order getOrderByOrderNo(String orderNo);

    /**
     * 查询订单状态
     * @param orderNo 订单号
     * @return 状态
     */
    Integer getOrderStatus(String orderNo);

    void  updateOrderStatus(String orderNo,Integer status);

    //删除超过规定时长且没有支付的订单
    void deleteExpiredOrder();

    //查询用户所有订单
    List<Order> getAllOrdersOfUser(int parseInt);

    //查询订单是否已支付
    boolean ifOrderPay(Integer courseId, Integer userId);

    //由于用户多次点击支付致使生成多个订单，后来用户支付成功，那么删除那些无效订单
    void deleteNoPayOrder(Integer courseId, Integer userId);

    //根据课程id创建订单
    String addOrderByClassId(Integer classId, Integer userId, Integer type);
}
